/*******************************************************************************
 * SDP Project AUT 2012
 * 
 *                ***********Driving Assistant************
 * Team:
 * Gisela, Deidre, Brijesh, Robert
 * 
 * This class sets up the streams to display the user guide.
 * 
 * @version 1.0
 * 
 * Copyright (c) 2011 by DrivingAssistant Team, Inc., All Rights Reserved.
 * 
 ******************************************************************************/
package com.drivingAssistant.model;

import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * UserGuide class
 * 
 */
public class UserGuide {
    
    // constants
    private static final String USER_GUIDE_FILE = "userGuide.txt";
    
    // file input and output streams
    private FileInputStream fis;
    private ByteOutputStream bos;

    /**
     *Constructor to create the UserGuide object.
     */
    public UserGuide() {
        // empty constructor
    }

    /**
     * Get the string representation of the UI guide from file
     * 
     * @return string representation of the UI guide
     */
    public String drivingAssistantUserGuide() {
        
        bos = new ByteOutputStream();
        try {
            fis = new FileInputStream(USER_GUIDE_FILE);
            for (int i = fis.read(); i != -1; i = fis.read()) {
                bos.write(i);
            }
        } catch (IOException ex) {
            Logger.getLogger(UserGuide.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                if (fis != null) {
                    fis.close();
                }
            } catch (IOException ex) {
                System.out.println("Error closing file ...");
            }
        }
        byte[] bosArray = bos.toByteArray();
        return new String(bosArray);
        
    }
    
}
